/*
 * 版权所有(c)  1952110078@qq.com  2022 - 2022
 */

package com.ldc.commonlibs.utils;

import android.content.Context;

/**
 * @author liudc
 * @since 2022/7/20 22:18
 */
public class DpUtil {

    public static int dp2px(Context context, float dpValue) {
        final float scale = context.getResources().getDisplayMetrics().density;
        float size = dpValue * scale + 0.5f;
        return (int) size;
    }

    public static int px2dp(Context context, float dpValue) {
        final float scale = context.getResources().getDisplayMetrics().density;
        float size = dpValue / scale + 0.5f;
        return (int) size;
    }
}
